﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using IDAL.RF.Package;
using Model.RF.Package;

namespace DAL.RF.Package
{
    public class Pack_Label_Print : BaseRepository_DT<Pack_Label_PrintInfo>, IPack_Label_Print
    {
        #region 静态变量部分
        private const string PARM_LABELPRINT_ID = "@ID";
        private const string PARM_LABELPRINT_PACKAGEPRODUCTSN = "@PackageProductSN";
        private const string PARM_LABELPRINT_RECORDTIME = "@RecordTime";
        private const string PARM_LABELPRINT_USERID = "@UserID";
        private const string PARM_LABELPRINT_PCIP = "@PCIP";
        #endregion

        #region 数据检索部分
        public IList<Pack_Label_PrintInfo> LoadEntities()
        {
            return null;
        }

        /// <summary>
        /// Get an individual category based on a provided id
        /// </summary>
        /// <param name="categoryId">Category id</param>
        /// <returns>Details about the Category</returns>
        public Pack_Label_PrintInfo LoadEntity<T1>(T1 id)
        {
            SqlParameter parm = GetParameter();
            //Bind the parameter
            parm.Value = id;
            return ExcuteSqlToGetEntity("Pack_Label_Print_GetbyID", parm);
        }

        public IList<Pack_Label_PrintInfo> GetPack_Label_Prints_byPackageProductSN(string packageProductSN)
        {
            SqlParameter parm = new SqlParameter(PARM_LABELPRINT_PACKAGEPRODUCTSN, SqlDbType.NVarChar,100);
            parm.Value = packageProductSN;
            return ExcuteSqlToGetEntities("Pack_Label_Print_GetbyPackageProductSN", parm);
        }

        public IList<Pack_Label_PrintInfo> GetPack_Label_Prints_byDT(DateTime starttime, DateTime stoptime)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = starttime;
            parms[1].Value = stoptime;
            return ExcuteSqlToGetEntities("Pack_Label_Print_GetbyDT", parms);
        }
        #endregion


        #region 重写基类部分
        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override Pack_Label_PrintInfo GetEntityRecord(SqlDataReader rdr)
        {
            Pack_Label_PrintInfo pro = new Pack_Label_PrintInfo()
            {
                ID = rdr.GetInt32(0),
                PackageProductSN = rdr.GetValue(1).ToString(),
                RecordTime = rdr.GetDateTime(2),
                UserID = rdr.GetValue(3).ToString(),
                PCIP = rdr.GetValue(4).ToString()
            };
            return pro;
        }

        public override Pack_Label_PrintInfo GetEntityRecord()
        {
            Pack_Label_PrintInfo pro = new Pack_Label_PrintInfo();
            return pro;
        }

        public override string GetInsertsp()
        {
            return "Pack_Label_Print_Insert";
        }

        public override string GetUpdatesp()
        {
            return null;
        }

        public override string GetDeletesp()
        {
            return null;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter Parm = new SqlParameter(PARM_LABELPRINT_ID, SqlDbType.Int, 4);
            return Parm;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
                    new SqlParameter(PARM_LABELPRINT_ID, SqlDbType.Int, 4),
					new SqlParameter(PARM_LABELPRINT_PACKAGEPRODUCTSN, SqlDbType.NVarChar, 100),
					new SqlParameter(PARM_LABELPRINT_RECORDTIME, SqlDbType.DateTime, 8),
                    new SqlParameter(PARM_LABELPRINT_USERID, SqlDbType.NVarChar, 10),
                    new SqlParameter(PARM_LABELPRINT_PCIP, SqlDbType.NVarChar, 20),
                };
            return parms;
        }

        public override void SetParameters(Pack_Label_PrintInfo entity, params SqlParameter[] Parms)
        {
            Parms[0].Value = entity.ID;
            Parms[1].Value = entity.PackageProductSN;
            Parms[2].Value = entity.RecordTime;
            Parms[3].Value = entity.UserID;
            Parms[4].Value = entity.PCIP;
        }
        #endregion
    }
}
